package com.kgc.controller;

import com.kgc.entity.ChoiceQuestion;
import com.kgc.service.ChoiceQuestionService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ChoiceQuestion)表控制层
 *
 * @author unicorn
 * @since 2020-05-21 14:05:07
 */
@RestController
@RequestMapping("choiceQuestion")
public class ChoiceQuestionController {
    /**
     * 服务对象
     */
    @Resource
    private ChoiceQuestionService choiceQuestionService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public ChoiceQuestion selectOne(@RequestParam("id") Integer id) {
        return this.choiceQuestionService.queryById(id);
    }

    @GetMapping(value = "queryChoiceQuestion")
    public List<ChoiceQuestion> queryChoiceQuestion(){
        return this.choiceQuestionService.queryChoiceQuestion();
    }

    @GetMapping(value = "deleteChoiceQuestion")
    public Integer deleteChoiceQuestion(@RequestParam("id") Integer id){
        return this.choiceQuestionService.deleteById(id);
    }

    @PostMapping(value = "insertChoiceQuestion")
    public Integer insertChoiceQuestion(@RequestBody ChoiceQuestion choiceQuestion){
        return this.choiceQuestionService.insert(choiceQuestion);
    }

    @PostMapping(value = "updateChoiceQuestion")
    public Integer updateChoiceQuestion(@RequestBody ChoiceQuestion choiceQuestion){
        return this.choiceQuestionService.update(choiceQuestion);
    }

}